import { Router } from 'preact-router';
import { signal } from '@preact/signals';
import Sidebar from './components/Sidebar';
import Welcome from './pages/Welcome';
import DeviceStatus from './pages/DeviceStatus';
import Settings from './pages/Settings';
import LedControl from './pages/LedControl';
import BuzzerControl from './pages/BuzzerControl';

// 全局状态
export const isConnected = signal(false);
export const deviceInfo = signal({});
export const cpuUsageHistory = signal(Array(301).fill(0));
export const memoryUsageHistory = signal(Array(301).fill(0));
export const temperatureHistory = signal(Array(301).fill(0));

export function App() {
  return (
    <div class="flex h-screen bg-gray-100">
      <Sidebar />
      <main class="flex-1 overflow-x-hidden overflow-y-auto bg-gray-100">
        <div class="container mx-auto px-6 py-8">
          <Router>
            <Welcome path="/" />
            <DeviceStatus path="/device-status" />
            <LedControl path="/led-control" />
            <BuzzerControl path="/buzzer-control" />
            <Settings path="/settings" />
          </Router>
        </div>
      </main>
    </div>
  );
} 